<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>
	<spring:message code="head.clothGarment"></spring:message>
	-
	<spring:message code="head.patternDirectory"></spring:message>
</title>
<!--公共样式-->
<link href="${pageContext.request.contextPath }/web/css/font/iconfont.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/web/css/NormalizeFile.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/web/css/public.css" />
<!--列表页面私有样式-->
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/web/css/subpage/list.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/h-ui/layui-v1.0.2/layui/css/layui.css" />
<style>
.list-exploit-like .yes{display: inline;}
</style>
</head>
<body>

   <form action="${pageContext.request.contextPath }/web/patternfilter/flowertypecatalog${pageInfo.page+1 }" method="post" id="formSearchHou">
     <input id="fileImgHou" type="hidden" name="fileImg" value="${param.fileImg}"/>
     <input id="keyHou" type="hidden" name="key" value="${param.key}"/>
     <input name="page" type="hidden" value="${pageInfo.page+1}"/>
   </form>
   <form action="${pageContext.request.contextPath }/web/patternfilter/flowertypecatalog${pageInfo.page-1 }" method="post" id="formSearchQian">
     <input id="fileImgQian" type="hidden" name="fileImg" value="${param.fileImg}"/>
     <input id="keyQian" type="hidden" name="key" value="${param.key}"/>
     <input name="page" type="hidden" value="${pageInfo.page-1}"/>
   </form>
	<div class="pagetitle"></div>
	<jsp:include page="../main/head.jsp"></jsp:include>
	
	<!--列表 begin-->
	<div class="contenter mt134">
	
		<!--筛选条件 begin-->
		
		<c:set var="canshu" value="-${canshu }-" />
		<div class="screening-condition">
			<c:forEach items="${shuju}" var="item">
				<div class="screening-condition-list">
					<div class="screening-condition-list-title">${item.fuji.ptName }：</div>
					<ul class="screening-condition-list-cont">
						<c:set var="flag" value="true" />
						<c:forEach items="${item.zi}" var="zi">
							<c:set var="ptid" value="-${zi.ptId }-" />
							<c:if test="${fn:contains(canshu,ptid)}">
								<c:set var="flag" value="false" />
							</c:if>
						</c:forEach>
						<li rel="" class="${flag?'on':''} designs_filter_selected"><spring:message code="pattern.unlimit"></spring:message></li>
						<c:forEach items="${item.zi}" var="zi">
							<c:set var="ptid" value="-${zi.ptId }-" />
							<li rel="${zi.ptId }" class="${fn:contains(canshu,ptid)?'on':''} designs_filter_selected">${zi.ptName }</li>
						</c:forEach>
					</ul>
					<div class="clearfix"></div>
				</div>
			</c:forEach>
		</div>
		<!--筛选条件 end-->

		<!--状态 begin-->
		<div class="condition">
			<ul class="condition-left">
				<li class="condition-left-title "><spring:message code="pattern.state"></spring:message></li>
				<li rel="" class="${fn:contains(canshu,'-0')?'':'on'} designs_filter_selected"><spring:message code="pattern.whole"></spring:message></li>
				<li rel="01" class="${fn:contains(canshu,'01')?'on':''} designs_filter_selected"><spring:message code="pattern.share"></spring:message></li>
				<li rel="02" class="${fn:contains(canshu,'02')?'on':''} designs_filter_selected"><spring:message code="pattern.vip"></spring:message></li>
				<li rel="03" class="${fn:contains(canshu,'03')?'on':''} designs_filter_selected"><spring:message code="pattern.new"></spring:message></li>
				<li rel="04" class="${fn:contains(canshu,'04')?'on':''} designs_filter_selected"><spring:message code="pattern.attention"></spring:message></li>
			</ul>
			<div class="flower-paging">
				<button onclick="shangyiye()" ${pageInfo.page<=1?'disabled="disabled"':''} class="page-turning"><</button>${pageInfo.page }<button onclick="xiayiye()" ${pageInfo.page>=pageInfo.totalPage?'disabled="disabled"':''} class="page-turning">></button><spring:message code="pattern.total"></spring:message><span class="page-total">${pageInfo.totalPage }</span><spring:message code="pattern.page"></spring:message>
			</div>
			<div class="clearfix"></div>
		</div>
		<!--状态 begin-->
		<ul class="index-exploit-list">
			<c:forEach var="item" items="${pattern }">
				<li>
					<a href="javascript:xiangqing('${item.P_VIP}','${item.P_ID}')" onfocus="blur();">
						<div class="list-bor">
						<c:if test="${item.P_IMG!=null}">
							<img src="${imgpath}${item.P_IMG}" />
						</c:if>
						<c:if test="${item.P_IMG==null}">
							<img src="${pageContext.request.contextPath }/web/img/screening-condition_04.png" />
						</c:if>
						</div>
						<div class="screening-condition-name">
							<div class="serial-number"><spring:message code="pattern.no"></spring:message>${item.P_NO }</div>
							<c:if test="${item.P_VIP==2 }">
							<div class="serial-vip serialvipt">VIP</div>
							</c:if>
							<div class="clearfix"></div>
							<div class="serial-size"><spring:message code="pattern.size"></spring:message>${item.CHICUN }cm</div>
						</div>
					</a>
					
					<c:if test="${member!=null}">
					<c:if test="${item.id==null }">
					<div onclick="guanzhu(this)" id="guanzhu" ael="${item.P_ID }" class="list-exploit-like">
					<img id="tupian" class="no" src="${pageContext.request.contextPath }/web/img/icon_addcollection.png" />
					</div>
					</c:if>
					<c:if test="${item.id!=null}">
					<div onclick="quxiaoguanzhu(this)" id="guanzhu" ael="${item.P_ID }"  class="list-exploit-like">
					<img id="tupian" class="yes" src="${pageContext.request.contextPath }/web/img/icon_alreadycollected.png" />
					</div>
					</c:if>
					</c:if>
				</li>
			</c:forEach>
		</ul>
		<%-- <c:if test="${pageInfo.page>1}">
		 <button type="button" onclick="shangyiye()"  class="${pageInfo.page>=pageInfo.totalPage?'before-page1':'before-page'}"><spring:message code="pattern.previous"></spring:message></button>
		 </c:if>
		 <c:if test="${pageInfo.page<pageInfo.totalPage}">
		<button type="button" onclick="xiayiye()" class="${pageInfo.page<=1?'before-page1':'next-page'}"><spring:message code="pattern.next"></spring:message></button>
		</c:if> 
		<div class="flower-paging">
			<button onclick="shangyiye()" ${pageInfo.page<=1?'disabled="disabled"':''} class="page-turning"><</button>${pageInfo.page }<button onclick="xiayiye()" ${pageInfo.page>=pageInfo.totalPage?'disabled="disabled"':''} type="button" class="page-turning">></button><spring:message code="pattern.total"></spring:message><span class="page-total">${pageInfo.totalPage }</span><spring:message code="pattern.page"></spring:message>
		</div>
		--%>
		
		<div id="demo4" style="text-align: center;">
         </div>
		<div class="clearfix"></div>
	</div>
	<!--列表 end-->
	<jsp:include page="../main/bottom.jsp"></jsp:include>
	<!--全局-->
	<script type="text/javascript" src="${pageContext.request.contextPath }/web/js/jquery-1.8.3.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/web/js/public.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/layer/2.1/layer.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/layui-v1.0.2/layui/layui.js"></script>
	<!--ie789下placeholder不兼容-->
	<script type="text/javascript" src="${pageContext.request.contextPath }/web/js/placeholder.js"></script>
	<script type="text/javascript">
	layui.use(['laypage', 'layer'], function(){
	layui.laypage({
	    cont: 'demo4'
	    ,pages: '${pageInfo.totalPage}'
	    ,first: false
	    ,curr:'${pageInfo.page}'
	    ,last: false
	    ,jump:function(obj, first){
	    	if(first){return;}
	    	
	    	var curr = obj.curr;
	    	var url = geturl();							
			if($("#formSearchHou").val()!=""||$("#keyHou").val()!="")
				{
				 $("#fileImgHou").submit();
				}
			else
				{
				
				if (url.length == 0) {
					url = '${pageContext.request.contextPath }/web/patternfilter/all/flowertypecatalog'+curr;
					location.href=url;
				}else{
					location.href = url+curr;
					return false;
				}
				}

	    }
	    
	  });
	});
		function geturl() {
			var url = '';
			var cs = new Array();
			$('.on').each(function() {
				if ($(this).attr('rel') && $(this).attr('rel').length > 0) {
					if($(this).attr('rel')=="02"){
					}
					cs.push($(this).attr('rel'));
				}
			});
			cs.sort();
			if (cs.length > 0) {
				url = '${pageContext.request.contextPath }/web/patternfilter/'
						+ cs.join('-') + '/flowertypecatalog';
			} else {
				url = ''
			}
			return url;
		}

		$('.designs_filter_selected').click(				
						function() {
							$("#fileImgQian").val("");
							$("#fileImgHou").val("");
							var flag = false;
							$(this).parent().find('.on').removeClass('on');
							$(this).addClass('on');

							var url = geturl();
							if (url.length == 0) {
								url = '${pageContext.request.contextPath }/web/patternfilter/all/flowertypecatalog1/';
								location.href=url;
							}else{
								if(url.indexOf("02") > 0 ){
									 $.ajax({url:'${pageContext.request.contextPath }/web/patternfilter/judge', async : false,type : "POST",  success :function(result){
						    			 var status=result.msg.status;
						    			 var desc=result.msg.desc;
						    			    if(status == 1){//没登录
						    			    	layer.confirm('<spring:message code="flowertypecatalog.notLogin"></spring:message>', {
					    			        	  btn: ['<spring:message code="flowertypecatalog.agreed"></spring:message>','<spring:message code="flowertypecatalog.unagree"></spring:message>'], //按钮
					    			        	  title:'<spring:message code="flowertypecatalog.message"></spring:message>'
					    			        	}, function(){
					    			        		location.href="${pageContext.request.contextPath}/web/member/login";
					    			        	},function(){
					    			        		location.reload(true);
					    			        	});
						    			    	flag=true;
						    			    }else if(status ==2){
						    			    	layer.confirm('<spring:message code="flowertypecatalog.applyForVIP"></spring:message>', {
						    			        	  btn: ['<spring:message code="flowertypecatalog.agreed"></spring:message>','<spring:message code="flowertypecatalog.unagree"></spring:message>'], //按钮
						    			        	  title:'<spring:message code="flowertypecatalog.message"></spring:message>'
						    			        	}, function(index){
						    			        		location.href="${pageContext.request.contextPath}/web/vip/applicationForVIP";
						    			        		layer.close(index);
						    			        	},function(index){
						    			        		layer.close(index);
						    			        		location.reload(true);
						    			        	});
						    			    	flag=true;
						    			    }
						    		  }
									 });
								}
								if(flag){
									return;
								}
								location.href = url+'1';
								return false;
							}
							return true;
						});
		
						function xiayiye() {
							var url = geturl();							
							if($("#formSearchHou").val()!=""||$("#keyHou").val()!="")
								{
								 $("#fileImgHou").submit();
								}
							else
								{
								
								if (url.length == 0) {
									url = '${pageContext.request.contextPath }/web/patternfilter/all/flowertypecatalog${pageInfo.page+1 }/';
									location.href=url;
								}else{
									location.href = url+${pageInfo.page+1 };
									return false;
								}
								}

							return true;
						}
						function shangyiye(){
							var url = geturl();
							if($("#fileImgQian").val()!=""||$("#keyQian").val()!="")
								{
								 $("#formSearchQian").submit();
								}
							else
								{
								if (url.length == 0) {
									url = '${pageContext.request.contextPath }/web/patternfilter/all/flowertypecatalog${pageInfo.page-1 }/';
									location.href=url;
								}else{
									location.href = url+${pageInfo.page-1 };
									return false;
								}
								}
							
							return true;
						}
		function xiangqing(vip,patternId){
			if(vip==2){
			$.ajax({url:'${pageContext.request.contextPath }/web/patternfilter/judge', async : false,type : "POST",  success :function(result){
   			 var status=result.msg.status;
   			 var desc=result.msg.desc;
   			    if(status == 1){//没登录
   			    	layer.confirm('<spring:message code="flowertypecatalog.notLogin"></spring:message>', {
			        	  btn: ['<spring:message code="flowertypecatalog.agreed"></spring:message>','<spring:message code="flowertypecatalog.unagree"></spring:message>'], //按钮
			        	  title:'<spring:message code="flowertypecatalog.message"></spring:message>'
			        	}, function(index){
			        		location.href="${pageContext.request.contextPath}/web/member/login";
			        	},function(index){
			        		
			        	});
   			    	flag=true;
   			    }else if(status ==2){
   			    	layer.confirm('<spring:message code="flowertypecatalog.applyForVIP"></spring:message>', {
   			        	  btn: ['<spring:message code="flowertypecatalog.agreed"></spring:message>','<spring:message code="flowertypecatalog.unagree"></spring:message>'], //按钮
   			        	  title:'<spring:message code="flowertypecatalog.message"></spring:message>'
   			        	}, function(index){
   			        		location.href="${pageContext.request.contextPath}/web/vip/applicationForVIP";
   			        		layer.close(index);
   			        	},function(index){
   			        		layer.close(index);
   			        	});
   			    	
   			    }else{
   			    	top.location.href='${pageContext.request.contextPath}/web/pattern/flowerCatalog?id='+patternId;
   			    }
   		  	}
			});
			}else{
				$.ajax({url:'${pageContext.request.contextPath }/web/patternfilter/judge', async : false,type : "POST",  success :function(result){
		   			 var status=result.msg.status;
		   			 var desc=result.msg.desc;
		   			    if(status == 1){//没登录
		   			    	layer.confirm('<spring:message code="flowertypecatalog.notLogin"></spring:message>', {
		   			        	  btn: ['<spring:message code="flowertypecatalog.agreed"></spring:message>','<spring:message code="flowertypecatalog.unagree"></spring:message>'], //按钮
		   			        	title:'<spring:message code="flowertypecatalog.message"></spring:message>'
		   			        	}, function(index){
		   			        		location.href="${pageContext.request.contextPath}/web/member/login";
		   			        	},function(index){
		   			        		
		   			        	});
		   			    	
		   			    }else{
		   			    	top.location.href='${pageContext.request.contextPath}/web/pattern/flowerCatalog?id='+patternId;
		   			    }
			}
		});
			}
		}
		
		function guanzhu(obj){
			$.ajax({
   			 url:'${pageContext.request.contextPath }/web/patternfilter/collect',
   			 async : false,
   			 data: {pId:$(obj).attr("ael")},
   			 type : "POST", 
   			 success :function(result){
   			 var status=result.msg.status;
   			 var desc=result.msg.desc;
   			 if(status == 0){
   				$(obj).find("img").attr("src","${pageContext.request.contextPath }/web/img/icon_alreadycollected.png");
   				$(obj).find("img").attr("class","yes");
   				$(obj).attr("onclick","quxiaoguanzhu(this)");
   				 layer.msg('<spring:message code="flowertypecatalog.successful"></spring:message>', {icon: 1,time: 1000}); 
   			 }else if(status == 2){//没登录
   				layer.confirm('<spring:message code="flowertypecatalog.notLogin"></spring:message>', {
	        	  btn: ['<spring:message code="flowertypecatalog.agreed"></spring:message>','<spring:message code="flowertypecatalog.unagree"></spring:message>'], //按钮
	        	  title:'<spring:message code="flowertypecatalog.message"></spring:message>'
	        	}, function(index){
	        		location.href="${pageContext.request.contextPath}/web/member/login";
	        	},function(index){
	        		
	        	});
   			 
   			    }else if(status ==1){//失败
   			    	layer.msg('<spring:message code="flowertypecatalog.failed"></spring:message>', {icon: 0,time: 1000}); 
   			    }
   			 }
   			 });
		}
		
		function quxiaoguanzhu(obj){
			$.ajax({
	   			 url:'${pageContext.request.contextPath }/web/patternfilter/delcollect',
	   			 async : false,
	   			 data: {pId:$(obj).attr("ael")},
	   			 type : "POST", 
	   			 success :function(result){
	   			 var status=result.msg.status;
	   			 var desc=result.msg.desc;
	   			 if(status == 0){
	   				$(obj).find("img").attr("src","${pageContext.request.contextPath }/web/img/icon_addcollection.png");
	   				$(obj).find("img").attr("class","no");
	   				$(obj).attr("onclick","guanzhu(this)");
	   				 layer.msg('<spring:message code="flowertypecatalog.successful"></spring:message>', {icon: 1,time: 1000}); 
	   			 }else if(status == 2){//没登录
	   				 
	   				layer.confirm('<spring:message code="flowertypecatalog.notLogin"></spring:message>', {
	  	        	  btn: ['<spring:message code="flowertypecatalog.agreed"></spring:message>','<spring:message code="flowertypecatalog.unagree"></spring:message>'], //按钮
	  	        	title:'<spring:message code="flowertypecatalog.message"></spring:message>'
	  	        	}, function(index){
	  	        		location.href="${pageContext.request.contextPath}/web/member/login";
	  	        	},function(index){
	  	        		
	  	        	});
	   			 
	   			    }else if(status ==1){//失败
	   			    	layer.msg('<spring:message code="flowertypecatalog.failed"></spring:message>', {icon: 0,time: 1000}); 
	   			    }
	   			 }
	   			 });
			
		}
	</script>
</body>
</html>